#include "fxcc/yml/Serializer.h"
#include "fxcc/core/graph/common/MaterialView.h"

using namespace fxcc::yml;
using namespace fxcc::graph::common;

template<>
void Serializer::Encode<MaterialNativeDataMap>(YAML::Node& node, const MaterialNativeDataMap& inst)
{
	SetVariable<MetaMapIndex>(node, "m_Index", inst.m_Index);
}

template<>
bool Serializer::Decode<MaterialNativeDataMap>(const YAML::Node& node, MaterialNativeDataMap& inst)
{
	GetVariable<MetaMapIndex>(node, "m_Index", inst.m_Index);
	return true;
}


template<>
void Serializer::Encode<EffectToken>(YAML::Node& node, const EffectToken& inst)
{
	SetVariable<std::string>(node, "m_Key", inst.m_Key);
}

template<>
bool Serializer::Decode<EffectToken>(const YAML::Node& node, EffectToken& inst)
{
	GetVariable<std::string>(node, "m_Key", inst.m_Key);
	return true;
}


template<>
void Serializer::Encode<MaterialView>(YAML::Node& node, const MaterialView& inst)
{
	Encode<fxcc::Base>(node, inst);
	SetVariable<fxcc::graph::common::MaterialNativeDataMap>(node, "m_Source", inst.m_NativeDataMap);
	SetVariable<fxcc::graph::common::EffectToken>(node, "m_EffectToken", inst.m_EffectToken);
	SetVariable<fxcc::graph::common::Params>(node, "m_Params", inst.m_Params);
	SetVariable<fxcc::graph::common::TextureMaps>(node, "m_Textures", inst.m_Textures);
}

template<>
bool Serializer::Decode<MaterialView>(const YAML::Node& node, MaterialView& inst)
{
	Decode<fxcc::Base>(node, inst);
	GetVariable<fxcc::graph::common::MaterialNativeDataMap>(node, "m_Source", inst.m_NativeDataMap);
	GetVariable<fxcc::graph::common::EffectToken>(node, "m_EffectToken", inst.m_EffectToken);
	GetVariable<fxcc::graph::common::Params>(node, "m_Params", inst.m_Params);
	GetVariable<fxcc::graph::common::TextureMaps>(node, "m_Textures", inst.m_Textures);
	return true;
}
